#!/bash/sh

#
DEPLOY_DIR=/xdfapp
JAR_FILE=$DEPLOY_DIR/study-alibaba-arthas-1.0.jar

#
pid=$(ps -ef | grep -v grep | grep $JAR_FILE | awk '{print $2}')
if [ ! -z "$pid" ]; then
  kill -9 $pid >/dev/null
  sleep 2
  echo '[INFO] Service Stopped'
fi

#
JAVA_MEM_OPTS=" -server -Xms2G -Xmx2G -Xmn512M"
JAVA_GC_OPTS=" -XX:MetaspaceSize=512M -XX:MaxMetaspaceSize=512M"
JAVA_OPTS=$JAVA_MEM_OPTS$JAVA_GC_OPTS

#
source /etc/profile
#java $JAVA_OPTS -jar $JAR_FILE
nohup java $JAVA_OPTS -jar $JAR_FILE >/dev/null 2>&1 &
if [ $? -eq 0 ];then
  echo '[INFO] service started'
else
  echo '[ERROR] service startup error'
fi